package edu.friday.controller;

import edu.friday.common.base.BaseController;
import edu.friday.common.result.RestResult;
import edu.friday.common.security.LoginUser;
import edu.friday.common.security.service.TokenService;
import edu.friday.model.SysMenu;
import edu.friday.service.SysMenuService;
import edu.friday.utils.http.ServletUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import edu.friday.model.vo.SysMenuVO;
import java.util.List;

@RestController
@RequestMapping("system/menu")
public class SysMenuController extends BaseController {
    @Autowired
    private SysMenuService menuService;
    @Autowired
    private TokenService tokenService;

    @GetMapping("/list")
    public RestResult list(SysMenuVO menu){
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        Long userId = loginUser.getUser().getUserId();
        List<SysMenu> menus = menuService.selectMenuList(menu,userId);
        return RestResult.success(menus);
    }
}
